package com.ydd.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ydd.dto.ArticleCollectOperateDTO;
import com.ydd.entity.YddUserData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Description TODO
 * @Author fang
 * @Date 2023-05-29 16:11
 */
@Mapper
public interface YddUserDataMapper extends BaseMapper<YddUserData> {
    /**
     * UserIndexService-show
     * @param articleId
     * @param userId
     * @param type
     * @return
     */
    Integer isLikeOrCollect(@Param("articleId") Long articleId, @Param("userId") Long userId, @Param("type") String type);

    /**
     * 根据用户id和操作类型查询文章id
     * @param yddUserId
     * @param type
     * @return
     */
    List<Integer> findArticleIdsByUserIdAndType(Long yddUserId, Integer type);

    /**
     * 查询用户对应文章点赞和收藏的个数（用于校验点赞和收藏是否重复操作）
     * @param articleCollectOperateDTO
     * @return
     */
    Integer userDataHandleCount(ArticleCollectOperateDTO articleCollectOperateDTO, Long yddUserId);

    /**
     * 根据用户id获取文章收藏数
     * @param yddUserId
     * @param i
     * @return
     */
    Integer getCollectNumOrLikeNumByUserId(Long yddUserId, Integer type);

    /**
     * 添加用户点赞/收藏文章数据
     * @param articleCollectOperateDTO
     * @param yddUserId
     */
    void insertData(ArticleCollectOperateDTO articleCollectOperateDTO, Long yddUserId);

    /**
     * 取消用户点赞/收藏文章数据
     * @param articleCollectOperateDTO
     * @param yddUserId
     */
    void deleteData(ArticleCollectOperateDTO articleCollectOperateDTO, Long yddUserId);
}
